Release 10.1A: OpenEdge Development:
Programming Interfaces
Generating reports with control breaks and aggregates
You can sort data using the
BYoption of the record phrase. For example, this block header in a report procedure sorts the Customer records by the Sales-rep code:
A control break separates sorted data into meaningful groups. Breaking sorted data by Sales-rep separates each sales rep’s customers into a separate break group. Break groups allow you to calculate summary data on subsets of data. For example, you could total the number of customers that each sales rep serves.
The
BREAKoption of the record phrase sets up your data for control breaks, as shown in this block header statement:
Once you’ve set up the control break, you can use the
aggregate phraseon an output statement item to calculate summary information. The diagram below shows the syntax of the aggregate phrase:
Table 7–1 describes the aggregate options.
For example, in the code below, Sales-rep is the control break, Balance is the expression, and the aggregate phrase with the
TOTALoption appears in parenthesis immediately after the expression in theDISPLAYstatement:
The
TOTALaggregate option totals the balances for each break group. Each time the value of Sales-rep changes in the sorted data, Progress creates another break group, and theTOTALBYaggregate function calculates and outputs the total of customer balances for that sales rep’s customers. Finally, at the end of the report, theTOTALoption calculates and outputs the total balances of all the break groups.
![]()
To see an example of control breaks and aggregate values:
- Open
i-10-05.pand run it.- Choose Report. The Report Output dialog box appears as shown in the following screen:
![]()
The members of each break group all have the same Sales-rep value. Notice that the report separates each break group with white space and outputs the result of the aggregate phrase options immediately following the break groups.
If you scroll to the bottom of the report, you can see the aggregate values for all the break groups.
- Choose OK, then Exit, and then press SPACEBAR to return to the Procedure Editor.
Here is the code for this procedure:
These notes point out the new features:
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |